<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="<c:url value='/css/Pub.css'/>"></link>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta charset="utf-8">
    <title>购物车页面</title>
    <script type="text/javascript">
        var path = "${pageContext.request.contextPath}";
    </script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/car.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<p>以下是你买的所有图书-><font color="red" style="font-family:bold;">订单明细</font>-->选择/添加收货地址->确认订单->网银付款或到货付款->查收货物</p>
<table id="table" class="table table-striped">
    <caption>购物车详情</caption>
    <thead>
    <tr>
        <th>书名</th>
        <th>价格</th>
        <th>数量</th>
        <th>合计</th>
        <th>增删数量</th>
    </tr>
    </thead>
    <tbody>
    <c:set value="0" var="sum"/>
    <c:forEach items="${sessionScope.car}" var="entry" varStatus="idx">
        <tr <c:if test="${idx.count%2==0}">class="even"</c:if>>
            <td>
                <a href="${pageContext.request.contextPath }/index?action=queryBook&id=${entry.value.id}">
                        ${entry.value.name}
                </a>
            </td>
            <td>
                    ${entry.value.currentPrice}
            </td>
            <td>
                    ${entry.value.amt}
            </td>
            <td>
                <fmt:formatNumber value="${entry.value.currentPrice*entry.value.amt}" pattern="#.##"/>
                <c:set value="${sum+(entry.value.currentPrice*entry.value.amt)}" var="sum"/>
                <fmt:formatNumber value="${sum}" pattern="#.##" var="sum"/>
            </td>
            <td>
                <button type="button" class="btn btn-primary"
                        data-loading-text="Loading..."
                        onclick="_add('${entry.value.id}')"
                >+
                </button>
                <button type="button" class="btn btn-primary"
                        data-loading-text="Loading..."
                        onclick="_del('${entry.value.id}')"
                >-
                </button>
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td>
            总金额：
            <label id="sum">
                ${sum}
            </label>
            元
        </td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td style="float: right;">
            <button class="btn btn-primary" data-loading-text="Loading..."
                    type="button" onclick="sure();">下一步->收货地址
            </button>
            <button class="btn btn-primary" data-loading-text="Loading..."
                    type="button" onclick="clearCar();">全部取消
            </button>
        </td>
    </tr>
    </tbody>
    <tfoot>
    </tfoot>
</table>

</body>
</html>